summaryrefslogtreecommitdiffstats
path: root/src/yuzu/configuration/configure_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/configuration/configure_system.cpp')
-rw-r--r--src/yuzu/configuration/configure_system.cpp212
1 files changed, 68 insertions, 144 deletions
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index f1ae312c6..c4833f4e7 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -3,16 +3,23 @@
#include <chrono>
#include <optional>
+#include <vector>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDateTimeEdit>
#include <QFileDialog>
#include <QGraphicsItem>
+#include <QLineEdit>
#include <QMessageBox>
#include "common/settings.h"
#include "core/core.h"
#include "core/hle/service/time/time_manager.h"
#include "ui_configure_system.h"
+#include "yuzu/configuration/config.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_system.h"
+#include "yuzu/configuration/shared_widget.h"
constexpr std::array<u32, 7> LOCALE_BLOCKLIST{
// pzzefezrpnkzeidfej
@@ -37,44 +44,32 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0;
}
-ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
- : QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
+ConfigureSystem::ConfigureSystem(Core::System& system_,
+ std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
+ const ConfigurationShared::Builder& builder, QWidget* parent)
+ : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
ui->setupUi(this);
- connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
- ui->rng_seed_edit->setEnabled(state == Qt::Checked);
- if (state != Qt::Checked) {
- ui->rng_seed_edit->setText(QStringLiteral("00000000"));
- }
- });
-
- connect(ui->custom_rtc_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
- ui->custom_rtc_edit->setEnabled(state == Qt::Checked);
- if (state != Qt::Checked) {
- ui->custom_rtc_edit->setDateTime(QDateTime::currentDateTime());
- }
- });
+ Setup(builder);
- const auto locale_check = [this](int index) {
- const auto region_index = ConfigurationShared::GetComboboxIndex(
- Settings::values.region_index.GetValue(true), ui->combo_region);
- const auto language_index = ConfigurationShared::GetComboboxIndex(
- Settings::values.language_index.GetValue(true), ui->combo_language);
+ const auto locale_check = [this]() {
+ const auto region_index = combo_region->currentIndex();
+ const auto language_index = combo_language->currentIndex();
const bool valid_locale = IsValidLocale(region_index, language_index);
ui->label_warn_invalid_locale->setVisible(!valid_locale);
if (!valid_locale) {
ui->label_warn_invalid_locale->setText(
tr("Warning: \"%1\" is not a valid language for region \"%2\"")
- .arg(ui->combo_language->currentText())
- .arg(ui->combo_region->currentText()));
+ .arg(combo_language->currentText())
+ .arg(combo_region->currentText()));
}
};
- connect(ui->combo_language, qOverload<int>(&QComboBox::currentIndexChanged), this,
- locale_check);
- connect(ui->combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
+ connect(combo_language, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
+ connect(combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
- SetupPerGameUI();
+ ui->label_warn_invalid_locale->setVisible(false);
+ locale_check();
SetConfiguration();
}
@@ -93,137 +88,66 @@ void ConfigureSystem::RetranslateUI() {
ui->retranslateUi(this);
}
-void ConfigureSystem::SetConfiguration() {
- enabled = !system.IsPoweredOn();
- const auto rng_seed =
- QStringLiteral("%1")
- .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'})
- .toUpper();
- const auto rtc_time = Settings::values.custom_rtc.value_or(QDateTime::currentSecsSinceEpoch());
-
- ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
- ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() &&
- Settings::values.rng_seed.UsingGlobal());
- ui->rng_seed_edit->setText(rng_seed);
-
- ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value());
- ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value());
- ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time));
- ui->device_name_edit->setText(
- QString::fromUtf8(Settings::values.device_name.GetValue().c_str()));
- ui->use_unsafe_extended_memory_layout->setEnabled(enabled);
- ui->use_unsafe_extended_memory_layout->setChecked(
- Settings::values.use_unsafe_extended_memory_layout.GetValue());
-
- if (Settings::IsConfiguringGlobal()) {
- ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue());
- ui->combo_region->setCurrentIndex(Settings::values.region_index.GetValue());
- ui->combo_time_zone->setCurrentIndex(Settings::values.time_zone_index.GetValue());
- } else {
- ConfigurationShared::SetPerGameSetting(ui->combo_language,
- &Settings::values.language_index);
- ConfigurationShared::SetPerGameSetting(ui->combo_region, &Settings::values.region_index);
- ConfigurationShared::SetPerGameSetting(ui->combo_time_zone,
- &Settings::values.time_zone_index);
-
- ConfigurationShared::SetHighlight(ui->label_language,
- !Settings::values.language_index.UsingGlobal());
- ConfigurationShared::SetHighlight(ui->label_region,
- !Settings::values.region_index.UsingGlobal());
- ConfigurationShared::SetHighlight(ui->label_timezone,
- !Settings::values.time_zone_index.UsingGlobal());
- }
-}
+void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
+ auto& core_layout = *ui->core_widget->layout();
+ auto& system_layout = *ui->system_widget->layout();
-void ConfigureSystem::ReadSystemSettings() {}
+ std::map<u32, QWidget*> core_hold{};
+ std::map<u32, QWidget*> system_hold{};
-void ConfigureSystem::ApplyConfiguration() {
- // Allow setting custom RTC even if system is powered on,
- // to allow in-game time to be fast forwarded
- if (Settings::IsConfiguringGlobal()) {
- if (ui->custom_rtc_checkbox->isChecked()) {
- Settings::values.custom_rtc = ui->custom_rtc_edit->dateTime().toSecsSinceEpoch();
- if (system.IsPoweredOn()) {
- const s64 posix_time{*Settings::values.custom_rtc};
- system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
- }
- } else {
- Settings::values.custom_rtc = std::nullopt;
+ std::vector<Settings::BasicSetting*> settings;
+ auto push = [&settings](auto& list) {
+ for (auto setting : list) {
+ settings.push_back(setting);
}
- }
+ };
- Settings::values.device_name = ui->device_name_edit->text().toStdString();
+ push(Settings::values.linkage.by_category[Settings::Category::Core]);
+ push(Settings::values.linkage.by_category[Settings::Category::System]);
- if (!enabled) {
- return;
- }
+ for (auto setting : settings) {
+ ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs);
- ConfigurationShared::ApplyPerGameSetting(&Settings::values.language_index, ui->combo_language);
- ConfigurationShared::ApplyPerGameSetting(&Settings::values.region_index, ui->combo_region);
- ConfigurationShared::ApplyPerGameSetting(&Settings::values.time_zone_index,
- ui->combo_time_zone);
- ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_unsafe_extended_memory_layout,
- ui->use_unsafe_extended_memory_layout,
- use_unsafe_extended_memory_layout);
-
- if (Settings::IsConfiguringGlobal()) {
- // Guard if during game and set to game-specific value
- if (Settings::values.rng_seed.UsingGlobal()) {
- if (ui->rng_seed_checkbox->isChecked()) {
- Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16));
- } else {
- Settings::values.rng_seed.SetValue(std::nullopt);
- }
+ if (widget == nullptr) {
+ continue;
}
- } else {
- switch (use_rng_seed) {
- case ConfigurationShared::CheckState::On:
- case ConfigurationShared::CheckState::Off:
- Settings::values.rng_seed.SetGlobal(false);
- if (ui->rng_seed_checkbox->isChecked()) {
- Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16));
- } else {
- Settings::values.rng_seed.SetValue(std::nullopt);
- }
- break;
- case ConfigurationShared::CheckState::Global:
- Settings::values.rng_seed.SetGlobal(false);
- Settings::values.rng_seed.SetValue(std::nullopt);
- Settings::values.rng_seed.SetGlobal(true);
+ if (!widget->Valid()) {
+ widget->deleteLater();
+ continue;
+ }
+
+ if (setting->Id() == Settings::values.region_index.Id()) {
+ // Keep track of the region_index (and langauge_index) combobox to validate the selected
+ // settings
+ combo_region = widget->combobox;
+ } else if (setting->Id() == Settings::values.language_index.Id()) {
+ combo_language = widget->combobox;
+ }
+
+ switch (setting->GetCategory()) {
+ case Settings::Category::Core:
+ core_hold.emplace(setting->Id(), widget);
break;
- case ConfigurationShared::CheckState::Count:
+ case Settings::Category::System:
+ system_hold.emplace(setting->Id(), widget);
break;
+ default:
+ widget->deleteLater();
}
}
+ for (const auto& [label, widget] : core_hold) {
+ core_layout.addWidget(widget);
+ }
+ for (const auto& [id, widget] : system_hold) {
+ system_layout.addWidget(widget);
+ }
}
-void ConfigureSystem::SetupPerGameUI() {
- if (Settings::IsConfiguringGlobal()) {
- ui->combo_language->setEnabled(Settings::values.language_index.UsingGlobal());
- ui->combo_region->setEnabled(Settings::values.region_index.UsingGlobal());
- ui->combo_time_zone->setEnabled(Settings::values.time_zone_index.UsingGlobal());
- ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal());
- ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal());
+void ConfigureSystem::SetConfiguration() {}
- return;
+void ConfigureSystem::ApplyConfiguration() {
+ const bool powered_on = system.IsPoweredOn();
+ for (const auto& func : apply_funcs) {
+ func(powered_on);
}
-
- ConfigurationShared::SetColoredComboBox(ui->combo_language, ui->label_language,
- Settings::values.language_index.GetValue(true));
- ConfigurationShared::SetColoredComboBox(ui->combo_region, ui->label_region,
- Settings::values.region_index.GetValue(true));
- ConfigurationShared::SetColoredComboBox(ui->combo_time_zone, ui->label_timezone,
- Settings::values.time_zone_index.GetValue(true));
-
- ConfigurationShared::SetColoredTristate(
- ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(),
- Settings::values.rng_seed.GetValue().has_value(),
- Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed);
-
- ConfigurationShared::SetColoredTristate(ui->use_unsafe_extended_memory_layout,
- Settings::values.use_unsafe_extended_memory_layout,
- use_unsafe_extended_memory_layout);
-
- ui->custom_rtc_checkbox->setVisible(false);
- ui->custom_rtc_edit->setVisible(false);
}